package cc.fs.kotlinproject.utlis

import android.text.Editable
import android.text.TextWatcher
import android.widget.EditText
import rx.Observable
import rx.subjects.BehaviorSubject

/**
 * Created by fostion on 2015/8/13.
 */
class Event{
    companion object{
        public fun textEvent(editText:EditText): BehaviorSubject<String>{
            val observable : BehaviorSubject<String> =  BehaviorSubject.create();
            editText.addTextChangedListener(object : TextWatcher{
                override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) {
                }

                override fun afterTextChanged(s: Editable?) {
                    observable.onNext(s.toString())
                }

                override fun onTextChanged(s: CharSequence, start: Int, before: Int, count: Int) {
                }
            })
            return observable
        }
    }
}